using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MovePoleParameterPanel : ShipUIParameterPanel
{
    public BindKey m_BindKeyOfForward;
    public BindKey m_BindKeyOfBack;
    public BindKey m_BindKeyOfLeft;
    public BindKey m_BindKeyOfRight;
    private void Awake()
    {
        m_BindKeyOfForward.m_OnKeyDown = OnBindKeyOfForwardChanged;
        m_BindKeyOfBack.m_OnKeyDown = OnBindKeyOfBackChanged;
        m_BindKeyOfLeft.m_OnKeyDown = OnBindKeyOfLeftChanged;
        m_BindKeyOfRight.m_OnKeyDown = OnBindKeyOfRightChanged;
    }
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {

    }
    public override void OnSelected(ShipUI shipUI)
    {
        base.OnSelected(shipUI);

        ShipUIMovePole movePole = shipUI as ShipUIMovePole;
        if (movePole == null)
            return;
        m_BindKeyOfForward.Init(movePole.bindKeyForward);
        m_BindKeyOfBack.Init(movePole.bindKeyBack);
        m_BindKeyOfLeft.Init(movePole.bindKeyLeft);
        m_BindKeyOfRight.Init(movePole.bindKeyRight);
    }
    void OnBindKeyOfForwardChanged(int newKey)
    {
        var movePole = m_ShipUI as ShipUIMovePole;
        movePole.bindKeyForward = newKey;
    }
    void OnBindKeyOfBackChanged(int newKey)
    {
        var movePole = m_ShipUI as ShipUIMovePole;
        movePole.bindKeyBack = newKey;
    }
    void OnBindKeyOfLeftChanged(int newKey)
    {
        var movePole = m_ShipUI as ShipUIMovePole;
        movePole.bindKeyLeft = newKey;
    }
    void OnBindKeyOfRightChanged(int newKey)
    {
        var movePole = m_ShipUI as ShipUIMovePole;
        movePole.bindKeyRight = newKey;
    }
}
